

function Tab(ele) {
    this.oTab = document.querySelector(ele);
    this.oBtns = this.oTab.querySelectorAll('button');
    this.oPs = this.oTab.querySelectorAll('p');
    this.init();
}


Tab.prototype.init = function () {
    this.oBtns.forEach((v, i) => {
        v.index = i;
    })
    this.oTab.onclick = e => {
        const target = e.target;
        if (target.tagName === 'BUTTON') {
            this.oBtns.forEach((v, i) => {
                v.classList.remove('active');
                this.oPs[i].classList.remove('show');
            })
            target.classList.add('active');
            this.oPs[target.index].classList.add('show');
        }
    }
}

